#dispatch-flanneld.sh
source /opt/k8s/bin/environment.sh
  for i in "${!NODE_IPS[@]}";
  do
    node_ip=${NODE_IPS[$i]}
    node_port=${NODE_PORTS[$i]} 
    echo ">>> ${node_ip}:${node_port} "
    scp -P ${node_port} /opt/flanneld/{flanneld,mk-docker-opts.sh} k8s@${node_ip}:/opt/k8s/bin/
    ssh -p ${node_port} k8s@${node_ip} "chmod +x /opt/k8s/bin/*"
    ssh -p ${node_port} root@${node_ip} "mkdir -p /etc/flanneld/cert && chown -R k8s /etc/flanneld"
    scp -P ${node_port} flanneld*.pem k8s@${node_ip}:/etc/flanneld/cert
    scp -P ${node_port} flanneld.service root@${node_ip}:/etc/systemd/system/    
  done
